package org.netty.im.connertor;

import org.netty.im.model.MessageWrapper;

import io.netty.channel.ChannelHandlerContext;

public interface ChatConnertor {
	/**
	 * 发送心跳检测 到客户端
	 * 
	 * @param hander
	 * @param wrapper
	 */
	public void heartbeatToClient(ChannelHandlerContext hander, MessageWrapper wrapper);

	/**
	 * 发送消息
	 * 
	 * @param wrapper
	 * @throws RuntimeException
	 */
	public void pushMessage(MessageWrapper wrapper) throws RuntimeException;

	/**
	 * 发送组消息
	 * 
	 * @param wrapper
	 * @throws RuntimeException
	 */
	public void pushGroupMessage(MessageWrapper wrapper) throws RuntimeException;

	/**
	 * 验证session
	 * 
	 * @param wrapper
	 * @return
	 * @throws RuntimeException
	 */
	public boolean validateSession(MessageWrapper wrapper) throws RuntimeException;

	public void close(ChannelHandlerContext hander, MessageWrapper wrapper);

	public void close(String sessionId);

	public void close(ChannelHandlerContext hander);

	public void connect(ChannelHandlerContext ctx, MessageWrapper wrapper);

	public boolean exist(String sessionId) throws Exception;

	/**
	 * 发送消息
	 * 
	 * @param sessionId
	 *            发送人
	 * @param wrapper
	 *            发送内容
	 * @throws RuntimeException
	 */
	public void pushMessage(String sessionId, MessageWrapper wrapper) throws RuntimeException;

	/**
	 * 获取用户唯一标识符
	 * 
	 * @param ctx
	 * @return
	 */
	public String getChannelSessionId(ChannelHandlerContext ctx);
}
